//
//  BKClassifyNoDataFooter.m
//  bestkeep
//
//  Created by utouu_mhm on 16/12/13.
//  Copyright © 2016年 utouu. All rights reserved.
//

#import "BKClassifyNoDataFooter.h"
#define RGB(r,g,b) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:1]
#import "masonry.h"
@interface BKClassifyNoDataFooter ()

@property (nonatomic,strong) UIView *footerView;

@end

@implementation BKClassifyNoDataFooter

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setUpViews];
    }
    return self;
}

-(void)setUpViews{
    
    UIView *footerVie = [self getViewWhenDataEndLoading];
    [self addSubview:footerVie];
    [footerVie mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.mas_top).offset(0);
        make.left.mas_equalTo(self.mas_left).offset(0);
        make.right.mas_equalTo(self.mas_right).offset(0);
        make.bottom.mas_equalTo(self.mas_bottom).offset(0);
        
    }];
}
- (UIView *)getViewWhenDataEndLoading {
    
    UIView *recommentFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 85)];
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 5, 40, 40)];
    UILabel *promptLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 150, 20)];
    [recommentFooterView addSubview:promptLabel];
    promptLabel.text = @"Sorry，暂时没有了~";
    [promptLabel setTextAlignment:NSTextAlignmentCenter];
    promptLabel.font = [UIFont systemFontOfSize:12];
    promptLabel.backgroundColor = [UIColor clearColor];
    promptLabel.textColor = RGB(182, 182, 182);
    [recommentFooterView addSubview:imageView];
    
    CGPoint center = recommentFooterView.center;
    imageView.center = CGPointMake(center.x, center.y-15);
    promptLabel.center = CGPointMake(center.x, center.y+20);
    imageView.image = [UIImage imageNamed:@"为空图标"];
    //设置左右label的渐变色
    UILabel *leftLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 1)];
    UILabel *rightLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 1)];
    leftLabel.backgroundColor = [UIColor clearColor];
    rightLabel.backgroundColor = [UIColor clearColor];
    [recommentFooterView addSubview:leftLabel];
    [recommentFooterView addSubview:rightLabel];
    leftLabel.center = CGPointMake(center.x - 80, center.y-15);
    rightLabel.center = CGPointMake(center.x + 80, center.y-15);
    CAGradientLayer *leftGradientLayer = [CAGradientLayer layer];
    leftGradientLayer.frame = leftLabel.frame;
    leftGradientLayer.type = kCAGradientLayerAxial;
    leftGradientLayer.cornerRadius = 0.5f;
    leftGradientLayer.masksToBounds = YES;
    leftGradientLayer.colors = [NSArray arrayWithObjects:(id)RGB(242, 242, 242).CGColor, (id)RGB(220, 220, 220).CGColor, nil];
    leftGradientLayer.startPoint = CGPointMake(0, 0.5);
    leftGradientLayer.endPoint = CGPointMake(1, 0.5);
    [recommentFooterView.layer insertSublayer:leftGradientLayer atIndex:0];
    CAGradientLayer *rightGradientLayer = [CAGradientLayer layer];
    rightGradientLayer.frame = rightLabel.frame;
    rightGradientLayer.colors = [NSArray arrayWithObjects:(id)RGB(220, 220, 220).CGColor, (id)RGB(242, 242, 242).CGColor, nil];
    rightGradientLayer.startPoint = CGPointMake(0, 0.5);
    rightGradientLayer.endPoint = CGPointMake(1, 0.5);
    rightGradientLayer.type = kCAGradientLayerAxial;
    rightGradientLayer.cornerRadius = 0.5f;
    rightGradientLayer.masksToBounds = YES;
    [recommentFooterView.layer insertSublayer:rightGradientLayer atIndex:0];
    return recommentFooterView;
    
}

@end
